<?php
declare (strict_types=1);

namespace app\school\validate\school\admin;

use think\Validate;

/**
 * 机构验证
 */
class School extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'    =>    ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'id'               => 'require',
        'title'            => 'require',
        'cates'            => 'require',
        'logo'             => 'require|gt:0',
        'level_id'         => 'require|gt:0',
        'admin_user_phone' => 'require|mobile',
        'intro'            => 'length:0,40',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'    =>    '错误信息'
     *
     * @var array
     */
    protected $message = [
        'title'            => '机构名称必须填写',
        'cates' => '请选择分类',
        'logo'             => '请上传LOGO',
        'level_id'         => '请选择等级',
        'intro'            => '简介只能40字以内',
        'admin_user_phone' => '请填写正确的机构管理员手机号',
        'id'               => '操作出错',
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'create' => ['title', 'cates', 'logo', 'level_id', 'admin_user_phone', 'intro'],
        'edit'   => ['id', 'title', 'cates', 'logo', 'level_id', 'intro'],
    ];

}
